package com.atguigu.yygh.sms.listener;

import com.atguigu.yygh.consts.MqConst;
import com.atguigu.yygh.sms.service.SmsService;
import com.atguigu.yygh.vo.msm.MsmVo;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2025/3/29 23:33
 */
@Component
public class SmsReceiver {
    @Autowired
    private SmsService smsService;
    @RabbitListener(bindings = @QueueBinding(
            exchange = @Exchange(name = MqConst.EXCHANGE_DIRECT_MSM, type = "direct"),
            value = @Queue(name = MqConst.QUEUE_MSM_ITEM, durable = "true"),
            key=MqConst.ROUTING_MSM_ITEM
    ))
    public void receive(MsmVo msmVo, Message message, Channel channel) {
        smsService.sendSmsVo(msmVo);
    }
}
